package org.fuys.etp.repo.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;

/**
 * 弹性线程池固定阶段配置
 * @TableName etp_fixed_config
 */
@TableName(value ="etp_fixed_config")
@Data
public class EtpFixedConfig implements Serializable {
    /**
     * 固定阶段配置版本 主键自增 根据version来切换版本
     */
    @TableId(type = IdType.AUTO)
    private Integer fixedVersion;

    /**
     * 负载等级 1~9逐步升级
     */
    private Object loadRating;

    /**
     * 缩容数据类型 比值 拒绝策略计数 阻塞队列长度 平均任务执行时间
     */
    private Object scaleNumType;

    /**
     * 缩容比较方式
     */
    private Object scaleCompareType;

    /**
     * 具体缩容阈值
     */
    private Integer scaleNum;

    /**
     * 扩容数据类型 意义同缩容
     */
    private Object expansionNumType;

    /**
     * 扩容比较方式
     */
    private Object expansionCompareType;

    /**
     * 具体扩容阈值
     */
    private Integer expansionNum;

    /**
     * 基本配置版本
     */
    private Integer baseConfigVersion;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        EtpFixedConfig other = (EtpFixedConfig) that;
        return (this.getFixedVersion() == null ? other.getFixedVersion() == null : this.getFixedVersion().equals(other.getFixedVersion()))
            && (this.getLoadRating() == null ? other.getLoadRating() == null : this.getLoadRating().equals(other.getLoadRating()))
            && (this.getScaleNumType() == null ? other.getScaleNumType() == null : this.getScaleNumType().equals(other.getScaleNumType()))
            && (this.getScaleCompareType() == null ? other.getScaleCompareType() == null : this.getScaleCompareType().equals(other.getScaleCompareType()))
            && (this.getScaleNum() == null ? other.getScaleNum() == null : this.getScaleNum().equals(other.getScaleNum()))
            && (this.getExpansionNumType() == null ? other.getExpansionNumType() == null : this.getExpansionNumType().equals(other.getExpansionNumType()))
            && (this.getExpansionCompareType() == null ? other.getExpansionCompareType() == null : this.getExpansionCompareType().equals(other.getExpansionCompareType()))
            && (this.getExpansionNum() == null ? other.getExpansionNum() == null : this.getExpansionNum().equals(other.getExpansionNum()))
            && (this.getBaseConfigVersion() == null ? other.getBaseConfigVersion() == null : this.getBaseConfigVersion().equals(other.getBaseConfigVersion()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getFixedVersion() == null) ? 0 : getFixedVersion().hashCode());
        result = prime * result + ((getLoadRating() == null) ? 0 : getLoadRating().hashCode());
        result = prime * result + ((getScaleNumType() == null) ? 0 : getScaleNumType().hashCode());
        result = prime * result + ((getScaleCompareType() == null) ? 0 : getScaleCompareType().hashCode());
        result = prime * result + ((getScaleNum() == null) ? 0 : getScaleNum().hashCode());
        result = prime * result + ((getExpansionNumType() == null) ? 0 : getExpansionNumType().hashCode());
        result = prime * result + ((getExpansionCompareType() == null) ? 0 : getExpansionCompareType().hashCode());
        result = prime * result + ((getExpansionNum() == null) ? 0 : getExpansionNum().hashCode());
        result = prime * result + ((getBaseConfigVersion() == null) ? 0 : getBaseConfigVersion().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", fixedVersion=").append(fixedVersion);
        sb.append(", loadRating=").append(loadRating);
        sb.append(", scaleNumType=").append(scaleNumType);
        sb.append(", scaleCompareType=").append(scaleCompareType);
        sb.append(", scaleNum=").append(scaleNum);
        sb.append(", expansionNumType=").append(expansionNumType);
        sb.append(", expansionCompareType=").append(expansionCompareType);
        sb.append(", expansionNum=").append(expansionNum);
        sb.append(", baseConfigVersion=").append(baseConfigVersion);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}